<?php
namespace app\audit_api\service;


use app\model\CallBackInfo;
use think\Model;
use app\lib\DingtalkCryptPlus;
use app\lib\Dingtalk;
class Accept extends Model
{

    /**
     * @introduction:将回调接口接收到的数据进行存库处理
     * @param $data
     * @author:cxh
     * @date: 2020/6/9 18:02
     */
    public function callBackInfoSave($data){

        $mCallBackInfo = new CallBackInfo();

        $info = $mCallBackInfo->insertGetId($data);
    }


    /**
     * @introduction:回调返回加密函数
     * @param $plain
     * @param $timeStamp
     * @param $nonce
     * @return array
     * @author:cxh
     * @date: 2020/6/8 19:26
     */
    public function EncryptMsg($plain, $timeStamp, $nonce)
    {

        $crypt = new DingtalkCryptPlus();

        $data = $crypt->doEncryptAudit($plain, $timeStamp, $nonce);

        return $data;

    }


    /**
     * @introduction:回调解密函数
     * @param $signature
     * @param $timeStamp
     * @param $nonce
     * @param $encrypt
     * @return array
     * @author:cxh
     * @date: 2020/6/8 19:26
     */
    public function DecryptMsg($signature, $timeStamp, $nonce, $encrypt)
    {
        $crypt = new DingtalkCryptPlus();
        $data = $crypt->doDecryptAudit($signature, $timeStamp, $nonce, $encrypt);

        return $data;
    }


    /**
     * @introduction:注册业务事件回调接口
     * @return array|mixed
     * @author:cxh
     * @date: 2020/6/8 19:26
     */
    public function registerCallBack(){

        $dingTalk = new Dingtalk();

        return $dingTalk->registerCallBack();
    }

    /**
     * @introduction:更新事件回调接口
     * @return array|mixed
     * @author:cxh
     * @date: 2020/6/8 19:27
     */
    public function updateCallBack(){

        $dingTalk = new Dingtalk();

        return $dingTalk->updateCallBack();
    }

    /**
     * @introduction:删除企业回调
     * @return array|mixed
     * @author:cxh
     * @date: 2020/6/8 19:27
     */
    public function deleteCallBack(){

        $dingTalk = new Dingtalk();

        return $dingTalk->deleteCallBack();
    }


}